# $Id: Makefile.in,v 1.2 2004/08/12 18:01:06 jan Exp $
#
# Use gmake on this Makefile.  It relies on the default rules.
# Use gmake -p to see the default rules.

CXX = @CXX@
CC = @CC@
MAKEDEPEND = $(CXX) -M
TPIEDIR = ../..

MINUSG = 0
MINUSPG = 0

LIBPATH = -L$(TPIEDIR)/lib
LINKLIBS = -ltpie -lm
INCLUDEPATH  = -I$(TPIEDIR)/include/ -I.
LDLIBS = $(LIBPATH) $(LINKLIBS)

override CPPFLAGS += $(INCLUDEPATH)

ifeq ($(MINUSG),1)
override CPPFLAGS += -g
else
override CPPFLAGS += -O3  #  -DNDEBUG
endif

ifeq ($(MINUSPG),1)
override CPPFLAGS += -pg 
endif

# The various test applications.
APPS = sssj pbsmj ascii2stream mbr


# Sources to the test applications.
APPSRC = $(patsubst %,%.cpp,$(APPS))

# Other C++ sources for common support routines.
COMMONCXXSRC = parse_args.cpp rectangle.cpp joinlog.cpp sortsweep.cpp sorting_adaptor.cpp intertree.cpp getopts.cpp

CXXSRC = $(APPSRC) $(COMMONCXXSRC)

# Common objects that go into most apps.
COMMONOBJ = $(COMMONCXXSRC:.cpp=.o)

# Translation rules:
%:%.o
	$(LINK.cc) $^ $(LDLIBS) -o $@

# Public targets.

all: $(APPS)

# What objects each of the apps acually need.
sssj: sssj.o $(COMMONOBJ)
pbsmj: pbsmj.o $(COMMONOBJ)
ascii2stream: ascii2stream.o rectangle.o
mbr: mbr.o rectangle.o

depend: cleandepend
	$(MAKEDEPEND) $(CPPFLAGS) $(CXXSRC) >> Makefile.depend

clean: cleandepend
	-rm -f $(CSRC:.c=.o) $(CXXSRC:.cpp=.o) $(APPS)

distclean: clean
	-rm -f *~ *.bak

backup:
	(set dn = `basename $$cwd `; cd ..; \
	tar cvf $$dn.tar $$dn/*.[CHch] $$dn/Makefile; gzip -f $$dn.tar)

# Private targets.

include Makefile.depend

cleandepend:
	-rm -f Makefile.depend

Makefile.depend:
	rm -f Makefile.depend; \
	$(MAKEDEPEND) $(CPPFLAGS) $(CXXSRC) >> Makefile.depend

.PHONY: clean depend cleandepend backup distclean all
